import java.util.Scanner;
class Conter{
    public volatile int flag = 0;
}
public class TestMain {
    public static void main(String[] args) {
        Conter conter = new Conter();
        Thread thread1 = new Thread(() -> {
           while (conter.flag == 0) {
                //一系列操作
           }
        });
        thread1.start();
        Thread thread2 = new Thread(() -> {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入：");
            conter.flag = scanner.nextInt();
        });
        thread2.start();
    }
}
